package cn.mysdp.biz.facade;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import cn.mysdp.biz.dto.request.*;
import cn.mysdp.biz.dto.response.*;
import cn.mysdp.biz.domain.*;
import cn.mysdp.biz.facade.*;
import cn.mysdp.biz.facade.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: SdpHistoryFacadeImpl
 * @Description:
 * @Author: SDP
 * @Date: 2021-10-30
 * @Version: 1.0
 * Table: sdp_history
 * Comment:
 * 
 */
@Service
public class SdpHistoryFacadeImpl extends SdpHistoryFacadeCustomImpl implements SdpHistoryFacade {

    static {
        beanClassNameMap.put("sdp_history", "sdpHistoryFacadeImpl");
        listMethodNameMap.put("sdp_history", "listSdpHistory");
        listMethodParameterClassNameMap.put("sdp_history", "SdpHistoryQueryRequest");
        updateMethodNameMap.put("sdp_history", "updateSdpHistory");
        updateMethodParameterClassNameMap.put("sdp_history", "SdpHistoryUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addSdpHistory(SdpHistoryAddRequest request) throws Exception {
        super.fixRequest("sdp_history", "add", request);
        return super.addSdpHistory(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateSdpHistory(SdpHistoryUpdateRequest request) throws Exception {
        SdpHistory record = null;
        record = sdpHistoryMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("sdp_history", "update", request, record);
        return super.updateSdpHistory(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteSdpHistory(SdpHistoryDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<SdpHistory> list = null;
            SdpHistoryExample example = new SdpHistoryExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = sdpHistoryMapper.selectByExample(example);
            fixRequest("sdp_history", "delete", request, list);
        } else {
            fixRequest("sdp_history", "delete", request);
        }
        return super.deleteSdpHistory(request);
    }

    @Override
    public SdpHistoryQueryResponse querySdpHistory(SdpHistoryQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        SdpHistoryQueryResponse result = super.querySdpHistory(request);
        checkResult("sdp_history", "query", request, result);
        return result;
    }

    @Override
    public List<SdpHistoryQueryResponse> listSdpHistory(SdpHistoryQueryRequest request) throws Exception {
        List<SdpHistoryQueryResponse> list = super.listSdpHistory(request);
        checkResult("sdp_history", "list", request, list);
        return list;
    }

    @Override
    public Integer countSdpHistory(SdpHistoryQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_history", "count", request);
        return super.countSdpHistory(request);
    }

    @Override
    public BaseStatResponse statSdpHistory(SdpHistoryQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_history", "stat", request);
        return super.statSdpHistory(request);
    }

    @Override
    public Integer clear(SdpHistoryForClearRequest request) throws Exception {
        super.fixRequest("sdp_history", "clear", request);
        return super.clear(request);
    }

}
